{extend name="common/main"}

{block name="css"}
<link rel="stylesheet" href="/static/assets/css/bootstrap.min.css" />
<style>
    .lai{
        float: none;
        display:inline-block;
    }
</style>
{/block}

{block name="body"}
<body data-type="widgets">
{include file="common/index"}
<div class="tpl-content-wrapper">
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <!--<h3>点数转让</h3>-->
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title  am-cf">充值套餐设置</div>
                        <div class="widget-body  am-fr">
                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r1">
                                <thead>
                                <tr>
                                    <th>呢称</th>
                                    <th>金额</th>
                                    <th>时间（天）</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="data" key="key" item="v"}
                                <tr class="gradeX">
                                    <td>{$v.name}</td>
                                    <td>{$v.price}</td>
                                    <td>{$v.overtime}</td>
                                    <td>
                                        <div class="tpl-table-black-operation">
                                            <a href="{:url('generate2_add')}?id={$v.id}">
                                                <i class="am-icon-pencil"></i> 修改
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                                </tbody>
                            </table>
                        </div>

                    </div>

                </div>



                </div>

            </div>


        </div>

    </div>

</div>
</div>
</body>
{/block}

{block name="js"}
<script type="text/javascript">
    $(function () {
        $('.button_jc').click(function () {
            $inpu=$(this).siblings('#lai').find('input').val();

            $.post("{:url('detection')}", {user_name:$inpu}, function(ret){
                if(ret.code != 200){
                    layer.msg(ret.msg, {icon: 2});
                    return false;
                }
                $('#user_name').val(ret.data);

            });
        })
        //全选，全不选
        $("#chkClkDevices").change(function () {
            $a= $(this).is(':checked');
            if ($a) {
                $("input[type='checkbox']").prop("checked",'checked');
            }else {
                $("input[type='checkbox']").prop("checked", false);
            }

        })
    });
    //提交
    function roleSubmit(){
        var form=document.getElementById("form");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('add_generate')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.reload();

                });
            }
        });
    }
    function sub_butt(t) {
        $sum=$('#weibo').val();//转让点数

        $.post("{:url('presenter')}", {user_name:$sum}, function(ret){
            if(ret.code != 200){
                layer.msg(ret.msg, {icon: 2});
                return false;
            }
            //成功
            // $('#user_name').val(ret.data);

        });
    }
    //导出
    function exc_button() {
        $type= $("[name='type']").val();
        $display=$("[name='display']").val();

        window.location.replace("{:url('export')}?type="+$type+"&display="+$display);

    }
    // 删除按钮
    function del(id) {
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('del')}", {id: id}, function(res) {
                if (res.code !=200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 800, icon: 1}, function() {
                    location.reload();
                });
            });
        }, function () {});
    }

    //全选
    $('#chkClkDevices').on("click",function(){
        var xz = $(this).prop("checked");//判断全选按钮的选中状态
        var ck = $('.id').prop("checked",xz); //让class名为qx的选项的选中状态和全选按钮的选中状态一致。
    });

    function fulldel() {
        if($('input[name="id"]:checked').val()==null){
            layer.msg('请先选择要删除的内容', {shade: 0.5, time: 1000, icon: 2});
            return false;
        }else{
            layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
                var chk_value = [];
                $('input[name="id"]:checked').each(function () {
                    chk_value.push($(this).val())
                })
                $arr = chk_value;
                $.post("{:url('fulldel')}", {id: $arr}, function(res) {
                    if (res.code !=200) {
                        layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                        return false;
                    }

                    layer.msg(res.msg, {shade: 0.5, time: 800, icon: 1}, function() {
                        location.reload();
                    });
                });
            } , function () {
                window.location.reload();
            });
        }
    }

</script>
{/block}